package com.edu.exam.entity.assessment;

import com.edu.exam.enums.assessment.StandardType;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 考核标准实体类
 * 所属模块：B-04 考核方案管理模块
 * 对应数据库表：assessment_plan_standard
 *
 * 根据B-04考核方案管理模块设计文档实现
 * 管理考核的评价标准，包括标准类型、内容要求、及格分数、等级划分等信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class AssessmentPlanStandard {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 关联方案ID
     */
    @Column(name = "scheme_id", nullable = false)
    private Long schemeId;

    /**
     * 方案编码
     */
    @Column(name = "scheme_code", length = 50)
    private String schemeCode;

    /**
     * 关联项目ID
     */
    @Column(name = "item_id")
    private Long itemId;

    /**
     * 项目名称
     */
    @Column(name = "item_name", length = 200)
    private String itemName;

    /**
     * 标准类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "type", nullable = false, length = 20)
    private StandardType type;

    /**
     * 标准名称
     */
    @Column(name = "standard_name", nullable = false, length = 100)
    private String standardName;

    /**
     * 标准内容
     */
    @Column(name = "content", columnDefinition = "TEXT")
    private String content;

    /**
     * 标准描述
     */
    @Column(name = "standard_description", columnDefinition = "TEXT")
    private String standardDescription;

    /**
     * 及格分数
     */
    @Column(name = "pass_score", precision = 8, scale = 2)
    private BigDecimal passScore;

    /**
     * 优秀分数
     */
    @Column(name = "excellent_score", precision = 8, scale = 2)
    private BigDecimal excellentScore;

    /**
     * 良好分数
     */
    @Column(name = "good_score", precision = 8, scale = 2)
    private BigDecimal goodScore;

    /**
     * 等级划分
     */
    @Column(name = "grade_level", columnDefinition = "TEXT")
    private String gradeLevel;

    /**
     * 评分细则
     */
    @Column(name = "scoring_details", columnDefinition = "TEXT")
    private String scoringDetails;

    /**
     * 扣分标准
     */
    @Column(name = "penalty_criteria", columnDefinition = "TEXT")
    private String penaltyCriteria;

    /**
     * 补充说明
     */
    @Column(name = "additional_notes", columnDefinition = "TEXT")
    private String additionalNotes;

    /**
     * 参考标准
     */
    @Column(name = "reference_standards", columnDefinition = "TEXT")
    private String referenceStandards;

    /**
     * 适用范围
     */
    @Column(name = "applicable_scope", length = 500)
    private String applicableScope;

    /**
     * 标准来源
     */
    @Column(name = "standard_source", length = 200)
    private String standardSource;

    /**
     * 制定日期
     */
    @Column(name = "establishment_date")
    private LocalDateTime establishmentDate;

    /**
     * 生效日期
     */
    @Column(name = "effective_date")
    private LocalDateTime effectiveDate;

    /**
     * 失效日期
     */
    @Column(name = "expiry_date")
    private LocalDateTime expiryDate;

    /**
     * 标准版本
     */
    @Column(name = "standard_version", length = 20)
    private String standardVersion;

    /**
     * 是否启用
     */
    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    /**
     * 创建时间
     */
    @Column(name = "create_time", nullable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除者ID
     */
    @Column(name = "deleter_id")
    private Long deleterId;

}